package com.sdust.controller;

import com.sdust.pojos.dto.UserAddFriendDto;
import com.sdust.pojos.dto.UserChatDto;
import com.sdust.pojos.dto.UserSendMessageDto;
import com.sdust.result.Result;
import com.sdust.service.ChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/chat")
public class ChatController {

    @Autowired
    private ChatService chatService;

    /**
     * 获取当前用户好友列表
     * @return
     */
    @GetMapping("/getFriendsList")
    public Result getFriendsList() {
        return chatService.getFriendsList();
    }

    /**
     * 获取聊天记录
     * @param dto
     * @return
     */
    @PostMapping("/getChatRecords")
    public Result getChatRecords(@RequestBody UserChatDto dto) {
        return chatService.getChatRecords(dto);
    }

    /**
     * 发送消息
     * @param dto
     * @return
     */
    @PostMapping("/sendMessage")
    public Result sendMessage(@RequestBody UserSendMessageDto dto) {
        return chatService.sendMessage(dto);
    }

    /**
     * 添加好友
     * @param dto
     * @return
     */
    @PostMapping("/addFriend")
    public Result addFriend(@RequestBody UserAddFriendDto dto) {
        return chatService.addFriend(dto);
    }
}
